<?PHP
class L2P{
	public $token;
    function __construct($token) {
        $this->token = $token;
    }
	
	public function GET($methodName, $urlParamArray){
		$queryString = http_build_query($urlParamArray);
		$url = "https://www3.elearning.rwth-aachen.de/_vti_bin/L2PServices/api.svc/v1/" . $methodName . "?" . $queryString;
		$opts = array(
			CURLOPT_SSL_VERIFYPEER => FALSE,
			CURLOPT_RETURNTRANSFER => true,
			CURLOPT_USERAGENT => 'Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)',
			CURLOPT_URL => $url
		);
		$ch = curl_init();
		curl_setopt_array($ch, $opts);
		$result = curl_exec($ch);
		
		return $result;
	}
	
	public function POST($methodName, $urlParamArray, $postParamArray){
		$url = "https://www3.elearning.rwth-aachen.de/_vti_bin/L2PServices/api.svc/v1/" . $methodName . "?" . http_build_query($urlParamArray);
		$opts = array(
			CURLOPT_SSL_VERIFYPEER => FALSE,
			CURLOPT_RETURNTRANSFER => true,
			CURLOPT_USERAGENT => 'Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)',
			CURLOPT_URL => $url,
			CURLOPT_POSTFIELDS => json_encode($postParamArray),
			CURLOPT_POST => TRUE,
			CURLOPT_HTTPHEADER => array("Content-type: application/json")
		);
		$ch = curl_init();
		curl_setopt_array($ch, $opts);
		$result = curl_exec($ch);
		return $result;
	}
}
?>